var url;
function newUser(){
    $('#dlg').dialog('open').dialog('center').dialog('setTitle','新增客户信息');
    $('#fm').form('clear');
    url = '/Lease/saveCustomer.htm';
}
function editUser(){
    var row = $('#dg').datagrid('getSelected');
    if (row){
        $('#dlg').dialog('open').dialog('center').dialog('setTitle','修改客户信息');
        $('#fm').form('load',row);
        url = '/Lease/editCustomer.htm?id='+row.id;
    }
}
function saveUser(){
    $('#fm').form('submit',{
        url: url,
        onSubmit: function(){
            return $(this).form('validate');
        },
        success: function(result){
            if (result == "fail"){
                $.messager.show({
                    title: 'Error',
                    msg: result.errorMsg
                });
            } else {
                $('#dlg').dialog('close');        // close the dialog
                $('#dg').datagrid('reload');    // reload the user data
            }
        }
    });
}
function doSearch(){
    $("#dg").datagrid("load",{
        name:$("#search").val()
    });
}
$(function(){
    $("#dg").datagrid({
        onDblClickRow:function(index,row){
        alert("id:"+row.id+" name:"+row.name);
        }
    });
})
